package iris.util
{
	public class StringProcessor
	{
		private var string:String;
		
		public function StringProcessor(string:String):void
		{
			this.string = string;
		}
		public function intercept(startTag:String, endTag:String, includeStartTag:Boolean, includeEndTag:Boolean):String
		{
			var startIndex:int = this.string.indexOf(startTag);
			if(startIndex == -1)
				throw new Error("invalide startTag: " + startTag);
				
			var endIndex:int = this.string.indexOf(endTag, startIndex + startTag.length);
			if(endIndex == -1)
				throw new Error("invalide endIndex: " + endIndex);

			if(!includeStartTag)
				startIndex = startIndex + startTag.length;
			if(includeEndTag)
				endIndex = endIndex + endTag.length;

			return this.string.substring(startIndex, endIndex);
		}

	}
}